package com.spring.gll.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MyInterceptor implements HandlerInterceptor{

    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
            throws Exception {

        Object name = request.getSession().getAttribute("name");
        if(name!=null){
            return true;
        }

        request.getRequestDispatcher("/WEB-INF/view/login.jsp").forward(request,response);
        return false;
    }
}
